/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.ce.commands.queries;

import com.bionic.ce.beans.Bankacc;
import com.bionic.ce.beans.Query;
import com.bionic.ce.businesslogic.BankAccService;
import com.bionic.ce.businesslogic.QueryService;
import com.bionic.ce.commands.ICommand;
import com.bionic.ce.manager.Config;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author MAXIM
 */
public class CommandDeleteMyQuery implements ICommand {

    @Override
    public String execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = null;
        Integer queryid = ((Query)request.getSession().getAttribute("myquery")).getQueryId();
        System.out.println(request.getSession().getAttribute("myquery"));
        System.out.println("queryid="+queryid);
        QueryService.deleteCurrentQuery(queryid);
        request.getSession().removeAttribute("myquery");

        (new CommandGoToMyQueries()).execute(request, response);
        page = Config.getInstance().getProperty(Config.GOTOMYQUERIES);
        return page;

    }
}